package www.wen.com.common.lib.view;

import android.view.View;

public abstract class OnMultipleClickListener implements View.OnClickListener {
    private long mLastClickTime = 0;
    private int clickId = 0;
    public static final int TIME_INTERVAL = 1000;

    @Override
    public final void onClick(View v) {
        if (clickId == v.getId()) {
            if (System.currentTimeMillis() - mLastClickTime >= TIME_INTERVAL) {
                onIClick(v);
                mLastClickTime = System.currentTimeMillis();
            } else {
                onAgain(v);
            }
        }else {
            onIClick(v);
            clickId = v.getId();
            mLastClickTime = System.currentTimeMillis();
        }
    }

    protected abstract void onIClick(View v);

    protected void onAgain(View v) {

    }
}
